package com.validator;

import org.springframework.web.multipart.MultipartFile;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author zdh
 */
public class MultipartFileNotEmptyConstraintValidator implements ConstraintValidator<MultipartFileNotEmptyCheck, MultipartFile> {

    @Override
    public void initialize(MultipartFileNotEmptyCheck constraintAnnotation) {
    }

    @Override
    public boolean isValid(MultipartFile multipartFile, ConstraintValidatorContext context) {
        return !(multipartFile==null || multipartFile.isEmpty());
    }
}

